var sort, ups, dsq;


function up() {
    sort = document.querySelector(".sort");
    ups = sort.querySelector(".up");
    ups.addEventListener("click", clickHandler);
    document.addEventListener("scroll", scrollHandler);
}
function scrollHandler(e) {
    var yop = e.target.documentElement.scrollTop

    if (yop > 500) {
        sort.style.display = "block";
    }
    if (yop < 300) {
        sort.style.display = "none"
    }

}

function clickHandler(e) {
    var num = document.documentElement.scrollTop
    dsq = setInterval(function () {
        var top = document.documentElement.scrollTop
        console.log(top);
        if (top <= 10) {
            clearInterval(dsq)
            top = 0
            return;
        }
        if (top > num) {
            clearInterval(dsq)
            return;
        }
        document.documentElement.scrollTop = top - 10
        console.log(num, top);

    }, 5)

}
export default{
    up
}